<?
  include('../init.php');

  $imgId= $_POST["imgId"];
  
  $sql = "SELECT project_id,project_img_path FROM project_img WHERE project_img_id = '".$imgId."'";
  $line = $db->queryUniqueObject($sql);
  
  $db->execute("DELETE FROM project_img WHERE project_img_id = '$imgId'");
  
  if(file_exists('../../images/projects/'.$line->project_id.'/'.$line->project_img_path)){
    unlink('../../images/projects/'.$line->project_id.'/'.$line->project_img_path);
  }

  echo 'success';
?>